/* SPDX-License-Identifier: GPL-2.0 */

/**
 * Copyright (C) 2025 Huawei Technologies Co., Ltd.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see <https://www.gnu.org/licenses/>.
 *
 * @file platform_info.h
 * @brief Hisilicon platform specific definitions
 */

#ifndef PLATFORM_INFO_H
#define PLATFORM_INFO_H

#include <linux/module.h>

MODULE_LICENSE("GPL");

/**
 * Definitions for CPU part IDs of newest LinxiCores
 * Note: these may be added to newer kernels (see arm64/include/asm/cputype.h)
 */
#define HISI_CPU_PART_LC9100	0xD02
#define HISI_CPU_PART_LC9200	0xD03


/** @struct hw_capabilities
 *  @brief  Struct containing hardware capabilities.
 */
typedef struct hw_capabilities {
	u64 cpu_part;
	struct {
		u64 cws_num;
		u64 max_mask;
		s64 restrict_granularity;
		u64 capacity;
		u64 cacheline_sz;
	} l2;
} hisi_hw_caps_t;

extern hisi_hw_caps_t hisi_hw_caps;

/**
 * Checks whether provided `cpu` is online.
 *
 * @param  cpu CPU to be checked.
 * @return     True in case CPU is online. False - otherwise.
 */
bool cman_drv_is_cpu_online(s32 cpu);

/**
 * Sets platform specific constants depending on underlying HW.
 *
 * @return 0 in case of successfull constants setting,
 *         -EIO in case error during write to one of HW registers.
 *         -ENOSYS in case driver is launched on unsupported platform.
 */
s32 cman_drv_platform_info_init(void);

#endif /* PLATFORM_INFO_H */
